package net.model.composite;

import java.util.Iterator;

public class Test {

	public static void main(String[] args) {
		
		IMenu root = new MenuNode("*");
		
		root.add(new MenuLeaf("*=>2", 8));
		IMenu sub1 = new MenuNode("*-A");
		sub1.add(new MenuLeaf("*-A=>3", 5));
		sub1.add(new MenuLeaf("*-A=>4", 10));
		IMenu trd1 = new MenuNode("*-A-B");
		trd1.add(new MenuLeaf("*-A-B=>5", 20));
		IMenu four1 = new MenuNode("*-A-B-C");
		four1.add(new MenuLeaf("*-A-B-C=>6", 21));
		trd1.add(four1);
		sub1.add(trd1);
		root.add(sub1);
		
		IMenu sub2 = new MenuNode("*-a");
		sub2.add(new MenuLeaf("*-a=>1", 50));
		root.add(sub2);
		
		root.print();
		Iterator itr = root.compositeIterator();
		while(itr.hasNext()) {
			IMenu menu = (IMenu)itr.next();
			menu.print();
		}
	}
}
